# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=outils
pkgver=0.13
pkgrel=1
pkgdesc="Port of some non-standard OpenBSD tools to Linux"
url="https://github.com/leahneukirchen/outils"
arch="all"
license="BSD-3-Clause ISC"
makedepends="openssl-dev>3 linux-headers"
options="!check" # upstream doesn't have a test suite
subpackages="$pkgname-doc
	$pkgname-sha256:_tool
	$pkgname-lndir:_tool
	$pkgname-rdate:_tool
	$pkgname-calendar:_tool
	$pkgname-lam:_tool
	$pkgname-what:_tool
	$pkgname-rs:_tool
	$pkgname-unvis:_tool
	$pkgname-md5:_tool
	$pkgname-sha1:_tool
	$pkgname-apply:_tool
	$pkgname-sha512:_tool
	$pkgname-vis:_tool
	$pkgname-signify:_tool
	$pkgname-jot:_tool
	$pkgname-cksum:_tool
	$pkgname-ts:_tool"
source="$pkgname-$pkgver.tar.gz::https://github.com/leahneukirchen/outils/archive/v$pkgver.tar.gz
	implicit-int.patch
	"

build() {
	make CC="$CC" CFLAGS="$CFLAGS" \
		-C "$builddir"
}

package() {
	make DESTDIR="$pkgdir" install \
		-C "$builddir"
}

_tool() {
	local name=$(echo $subpkgname | cut -d '-' -f2)
	pkgdesc="$name tool from $pkgname"

	if [ "$name" = "cksum" ]; then
		depends="!coreutils $depends"
	fi

	if [ "$name" = "rdate" ]; then
		mkdir -p "$subpkgdir"/usr/sbin
		mv "$pkgdir"/usr/bin/$name \
			"$subpkgdir"/usr/sbin/$name
	else
		mkdir -p "$subpkgdir"/usr/bin
		mv "$pkgdir"/usr/bin/$name \
			"$subpkgdir"/usr/bin/$name
	fi

	rmdir "$pkgdir"/usr/bin/ 2>/dev/null || true
	rmdir "$pkgdir"/usr/ 2>/dev/null || true
}

sha512sums="
8838dbce8e4df56846f1ad2ec1012f072584e5ac11000f378fb3303e615c084e5903f6d759078f8c24b836cc771652d815b737a50e69e99f6a55346f23e98bfd  outils-0.13.tar.gz
1f6dca9ebe9b231b7041fb49bd48dbc09ab9a90f85d47075a6301d00269c1274a190562df0b61ea974618700d1160ef30c0f2aea2c003113f07b0c7fd4ba389c  implicit-int.patch
"
